using System.Collections.Generic;
using UnityEngine;

namespace Jerry.UiFrame
{
    public class NetImageCache
    {
        private static NetImageCache _instance;
        
        public static NetImageCache Instance => _instance ??= new NetImageCache();
        
        public Dictionary<string, Sprite> Cache = new Dictionary<string, Sprite>();

        public Sprite Get(string url)
        {
            return Cache.GetValueOrDefault(url);
        }

        public void Add(string url, Sprite sprite)
        {
            if (!Cache.ContainsKey(url))
            {
                Cache.Add(url, sprite);
            }
        }
    }
}